package com.briup.web.controller;

import com.briup.DTO.AddOrUpdateFenceHouseDTO;
import com.briup.annotation.SystemLog;
import com.briup.exception.SystemException;
import com.briup.mapper.FenceHouseMapper;
import com.briup.result.PageTemplate;
import com.briup.result.Result;
import com.briup.service.FenceHouseService;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@Api(tags = "栏舍管理")
@RequestMapping("/fenceHouse")
public class FenceHouseController {
   @Autowired
   private FenceHouseService fenceHouseService;

    @GetMapping("/query")
    @ApiOperation("分页多条件查询栏舍信息接口")
//    @SystemLog(business = "分页多条件查询栏舍信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "当前页码"),
            @ApiImplicitParam(name = "pageSize",value = "每页大小"),
            @ApiImplicitParam(name = "fhName",value = "舍")
    })
    public Result query(Integer pageNum,Integer pageSize,String fhName) throws SystemException {
        PageTemplate pageTemplate=fenceHouseService.fhquery(pageNum,pageSize,fhName);
        return Result.success(pageTemplate);
    }
    @ApiOperation("根据栏舍编号查询栏舍信息以及栏圈信息接口")
//    @SystemLog(business = "根据栏舍编号查询栏舍信息以及栏圈信息")
    @GetMapping("/selectById")
    public Result selectById(String fhId){
        return fenceHouseService.selectById(fhId);
    }
    @PostMapping("/saveOrUpdate")
    @ApiOperation("新增或修改栏舍接口")
    @SystemLog(business = "新增或修改栏舍")
    public Result saveOrUpdate(@RequestBody AddOrUpdateFenceHouseDTO addOrUpdateFenceHouseDTO) throws SystemException {
        return fenceHouseService.fenceSaveOrUpdate(addOrUpdateFenceHouseDTO);
    }

    @DeleteMapping("deleteById/{hId}")
    @ApiOperation("根据id删除栏舍信息接口")
    @SystemLog(business = "根据id删除栏舍信息")
    public Result deleteById(@PathVariable String hid) throws SystemException {
        return fenceHouseService.deleteById(hid);
    }
    @DeleteMapping("deleteByIdAll")
    @ApiOperation("批量删除栏舍信息接口")
    @SystemLog(business = "批量删除栏舍信息")
    public Result deleteByIdAll(@RequestBody List<String> hids) throws SystemException {
        return fenceHouseService.deleteByIdAll(hids);
    }

}
